/**
 * author:wos
 * time:2024-1-4
 * title:目录权限查询列表
 */
const {makeSqlSelect} = require('../../../utils/makeSql')
const parseQueryParams = require("../../../utils/parseQueryParams");

async function list(ctx, next) {
    const sqlConfig = {
        tableName:"sys_post",
        whereJoin:"AND", //关联字
        like:['postName'], //使用where中like的key
        timeInterval:['createTime'], // 时间范围的where key
        orderby:"ORDER BY postSort desc" //order by 语句
    }
    const url = ctx.request.url
    const selectJson = Object.assign({}, parseQueryParams(url))
    const sql = makeSqlSelect(selectJson, sqlConfig)
    try {
        if (!sql){
            global.serverError(ctx,'技术故障')
            return false
        }
        let rs = await global.query(sql)
        global.response(ctx, {
            "status":200,
            "code": 200,
            "data": {
                "total":rs.length,
                "rows":rs
            },
            "msg":'success'
        })
    } catch (err) {
        global.serverError(ctx)
    }
}
module.exports = list


